<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="__STATIC__/bootstrap-table/js/dropdown.js"></script>
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap.css">
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
</head>
<body>
<div class="x-nav">
<span class="layui-breadcrumb">
        <a href="#">资源管理</a>
        <a href="#">体育用书</a>
        <a href="#">书籍列表</a>
        <a href="#">添加书籍</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<br>
<form class="layui-form" action="" id="book" onsubmit="return false">
    <div class="layui-form-item">
        <label class="layui-form-label">类别</label>
        <div class="layui-input-block" style="width: 20%">
            <select name="catid" lay-verify="required" style="height: 40px">
                <option value="">请选择</option>
                {foreach $type as $value}
                <?php  $nbsp = str_repeat("&nbsp;",($value['level'])*3); ?>
                {if $value.pid == 0}
                <option value="{$value.id}">{$nbsp}|--{$value.catname}</option>
                {else /}
                <option value="{$value.id}">{$nbsp}|--{$value.catname}</option>
                {/if}
                {/foreach}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">书籍名</label>
        <div class="layui-input-block" style="width: 20%;">
            <input type="text" name="title" required  lay-verify="required" placeholder="请输入书籍名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">作者</label>
        <div class="layui-input-block" style="width: 20%;">
            <input type="text" name="creator" required  lay-verify="required" placeholder="请输入作者" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出版社</label>
        <div class="layui-input-block" style="width: 20%;">
            <input type="text" name="publisher" required  lay-verify="required" placeholder="请输入出版社" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">出版日</label>
        <div class="layui-input-block" style="width: 20%;">
            <input type="text" name="date" required  lay-verify="required" placeholder="请输入出版日期" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">年份</label>
        <div class="layui-input-block" style="width: 20%;">
            <input type="text" name="pressyear" required  lay-verify="required" placeholder="请输入出版年份" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">书号</label>
        <div class="layui-input-block" style="width: 20%;">
            <input type="text" name="identifier" required  lay-verify="required" placeholder="ISBN 书号 唯一编号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">封面</label>
        <div class="layui-input-block" style="width: 20%;">
            <input type="text" name="thumb" required  lay-verify="required" placeholder="请输入封面链接" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block" style="width: 20%;">
            <input type="text" name="url" required  lay-verify="required" placeholder="请输入pdf链接" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" id="add">立即添加</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
</html>
<script>
    $("#add").click(function(){
            $.ajax({
                url:"{:url('/book/add')}",
                data:$("#book").serialize(),
                type:"post",
                dataType:"json",
                success:function(res){
                    if(res.code){
                        layer.msg(res.msg,{icon:1,time:2000},function(){
                            window.location.reload();
                        });
                        return;
                    }else{
                        layer.msg(res.msg,{icon:5,time:2000});
                        return;
                    }
                }
            })
    })
</script>